# 项目：python_project
# 文件：testaddchoice
# 作者：WuTong
# 日期：2025/5/22,19:52
# coding:utf-8
from time import sleep

import pytest
import requests

from YunDuanBossTest.tools import Util


class TestAddChoice:
    @classmethod
    def setup_class(cls):
        login_url = 'http://localhost:8080/YunDuanBoss/login/userLogin'
        login_data = {'userName':'YD001', 'userPass': 'YunDuan123', 'checkcode': '0000', 'remember': 'y'}
        cls.session = requests.session()
        cls.session.post(url=login_url, data=login_data)
        cls.add_choice = Util.get_info('add_choices')
        return cls.session

    def test_add_choice(self):
        add_choice_url = 'http://localhost:8080/YunDuanBoss/exercise/addOption'
        add_choice_data = Util.read_json('../datas/conf.json')['add_choice_data']
        self.session.post(url=add_choice_url, data=add_choice_data)
        sleep(3)
        query_choice_sql = 'select content from exercise order by id desc'
        find_choice = Util.query(query_choice_sql)[0][0]
        return find_choice


